package be.music.tool.practice;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import be.music.tool.alert.Alert;
import be.music.tool.comparator.AlertComparator;
import be.music.tool.time.Time;

public abstract class AbstractPracticeEvent implements PracticeEvent {

	private Time startTime;
	private Time endTime;
	
	private String comment;
	private String description;
	
	private List<Alert> alerts;
	
	public AbstractPracticeEvent() {
		alerts = new ArrayList<Alert>();
	}
	
	/**
	 * @return the comment
	 */
	public String getComment() {
		return comment;
	}
	/**
	 * @param comment the comment to set
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the startTime
	 */
	public Time getStartTime() {
		return startTime;
	}
	/**
	 * @param startTime the startTime to set
	 */
	public void setStartTime(Time startTime) {
		this.startTime = startTime;
	}
	/**
	 * @return the endTime
	 */
	public Time getEndTime() {
		return endTime;
	}
	/**
	 * @param endTime the endTime to set
	 */
	public void setEndTime(Time endTime) {
		this.endTime = endTime;
	}

	@Override
	public boolean coversTime(Time time) {
		
		return time.isBetween(startTime, endTime);
		
	}

	@Override
	public void addAlert(Alert alert) {
		
		alerts.add(alert);
		Collections.sort(alerts, new AlertComparator());

		
	}
	
	@Override
	public void removeAlert(Alert alert) {
		alerts.remove(alert);
		
	}
	
	@Override
	public Iterator<Alert> getAlertsIterator() {
		return alerts.iterator();
	}

}
